package j2025.j03;

import java.util.ArrayList;
import java.util.List;
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}
/**
 * @Author 猫大仙
 */
public class j0324 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> ret = new ArrayList<>();
        inOrder(root, ret);
        return ret;
    }
    public void inOrder(TreeNode root,List<Integer> ret) {
        if (root == null) return;
        inOrder(root.left,ret);
        ret.add(root.val);
        inOrder(root.right,ret);
    }


    public int maxDepth(TreeNode root) {
        if(root==null) return 0;
        int left = maxDepth(root.left);
        int right = maxDepth(root.right);
        return Math.max(left, right) + 1;
    }
}
